import json

def json2csv(a):
    ret = ""
    for i in a:
        tmp = []
        for j in i:
            if isinstance(j, int):
                tmp.append(str(j))
            else:
                tmp.append(j)
        ret += ",".join(tmp) + '\n'
    return ret[:-1]

fnm = input("input filename:")
ofnm = input("output filename:")

data = {}

with open(fnm) as f:
    data = json.loads(f.read())

dataTableNames = ["student", "user", "stu_vol", "volunteer", "class_vol"]

for i in dataTableNames:
    with open(ofnm + ".%s.csv" % i, "w") as f:
        f.write(json2csv(data[i]))

